package com.by.bean;


import lombok.Data;

@Data
public class BeanResult<T>  {
    private int code;
    private String msg;
    private T data;




    /**
     * 成功且无数据
     * @param <T>
     * @return
     */
    public static <T> BeanResult<T> success(){
        BeanResult<T> beanResult = new BeanResult<T>();
        beanResult.code = ApiCode.SUCCESS;
        return beanResult;
    }
    /**
     * 成功且有数据
     * @param <T>
     * @return
     */
    public static <T> BeanResult<T> success(T data){
        BeanResult<T> beanResult = new BeanResult<T>();
        beanResult.code = ApiCode.SUCCESS;
        beanResult.data = data;
        return beanResult;
    }
    /**
     * 失败
     * @param <T>
     * @return
     */
    public static <T> BeanResult<T> error(String msg){
        BeanResult<T> beanResult = new BeanResult<T>();
        beanResult.code = ApiCode.FAIL;
        beanResult.msg = msg;
        return beanResult;
    }



}
